import { Module } from "@nestjs/common"
import { APP_GUARD } from "@nestjs/core"
import { LoginService } from "./login.service"
import { LoginController } from "./login.controller"
import { JwtModule } from '@nestjs/jwt'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { AuthGuard } from "./auth.guard"
import { UsersModule } from "../users/user.module"

@Module({
    imports: [
        UsersModule,
        ConfigModule,
        JwtModule.registerAsync({
            imports: [ConfigModule],
            useFactory: async (configService: ConfigService) => ({
                // secret: configService.get<string>('JWT_SECRET'),
                secret:'3a7934ed56223528bb31eeb616394ac6c55bfb2acb63eafe7f6b1868ecd753ac',
                signOptions: { expiresIn: '60h' },
            }),
            inject: [ConfigService],
        }),
    ],
    controllers: [LoginController],
    providers: [
        LoginService,
        {
            provide: APP_GUARD,
            useClass: AuthGuard
        }
    ],
    exports: [LoginService],
})
export class LoginModule {}